FROM node:14.7.0-alpine3.12 AS dev
WORKDIR /usr/app
COPY package.json .
RUN npm config set registry https://registry.npm.taobao.org
RUN npm i
COPY . .
RUN npm run build

FROM node:14.7.0-alpine3.12 AS prod
ENV NODE_ENV=production
WORKDIR /usr/app
COPY --from=dev /usr/app/dist ./dist
COPY --from=dev /usr/app/public ./public
COPY --from=dev /usr/app/package.json ./package.json

RUN npm config set registry https://registry.npm.taobao.org
RUN npm install --only=production

ENV PORT 3000
EXPOSE 3000

ENTRYPOINT ["npm", "start"]